package cn.snoworld.handler;

import lombok.extern.slf4j.Slf4j;
import cn.snoworld.dto.CommonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public CommonResult exception(Exception e) {

        log.error(e.getMessage());

        e.printStackTrace();// TODO:上线记得删

        return CommonResult.FAIL(e.getStackTrace());
    }
}
